package com.klw.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.klw.common.annotation.Log;
import com.klw.common.core.controller.BaseController;
import com.klw.common.core.domain.AjaxResult;
import com.klw.common.enums.BusinessType;
import com.klw.business.domain.KlwStudentBehavior;
import com.klw.business.service.IKlwStudentBehaviorService;
import com.klw.common.utils.poi.ExcelUtil;
import com.klw.common.core.page.TableDataInfo;

/**
 * 学生行为记录Controller
 * 
 * @author klw
 * @date 2025-09-13
 */
@RestController
@RequestMapping("/core/behavior")
public class KlwStudentBehaviorController extends BaseController
{
    @Autowired
    private IKlwStudentBehaviorService klwStudentBehaviorService;

    /**
     * 查询学生行为记录列表
     */
    @PreAuthorize("@ss.hasPermi('core:behavior:list')")
    @GetMapping("/list")
    public TableDataInfo list(KlwStudentBehavior klwStudentBehavior)
    {
        startPage();
        List<KlwStudentBehavior> list = klwStudentBehaviorService.selectKlwStudentBehaviorList(klwStudentBehavior);
        return getDataTable(list);
    }

    /**
     * 导出学生行为记录列表
     */
    @PreAuthorize("@ss.hasPermi('core:behavior:export')")
    @Log(title = "学生行为记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KlwStudentBehavior klwStudentBehavior)
    {
        List<KlwStudentBehavior> list = klwStudentBehaviorService.selectKlwStudentBehaviorList(klwStudentBehavior);
        ExcelUtil<KlwStudentBehavior> util = new ExcelUtil<KlwStudentBehavior>(KlwStudentBehavior.class);
        util.exportExcel(response, list, "学生行为记录数据");
    }

    /**
     * 获取学生行为记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('core:behavior:query')")
    @GetMapping(value = "/{behaviorId}")
    public AjaxResult getInfo(@PathVariable("behaviorId") Long behaviorId)
    {
        return success(klwStudentBehaviorService.selectKlwStudentBehaviorByBehaviorId(behaviorId));
    }

    /**
     * 新增学生行为记录
     */
    @PreAuthorize("@ss.hasPermi('core:behavior:add')")
    @Log(title = "学生行为记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KlwStudentBehavior klwStudentBehavior)
    {
        return toAjax(klwStudentBehaviorService.insertKlwStudentBehavior(klwStudentBehavior));
    }

    /**
     * 修改学生行为记录
     */
    @PreAuthorize("@ss.hasPermi('core:behavior:edit')")
    @Log(title = "学生行为记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KlwStudentBehavior klwStudentBehavior)
    {
        return toAjax(klwStudentBehaviorService.updateKlwStudentBehavior(klwStudentBehavior));
    }

    /**
     * 删除学生行为记录
     */
    @PreAuthorize("@ss.hasPermi('core:behavior:remove')")
    @Log(title = "学生行为记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{behaviorIds}")
    public AjaxResult remove(@PathVariable Long[] behaviorIds)
    {
        return toAjax(klwStudentBehaviorService.deleteKlwStudentBehaviorByBehaviorIds(behaviorIds));
    }
}
